package backend

import (
	"github.com/docker/docker/api/types"
	"github.com/docker/docker/client"
)

func (a App) InitDocker() *client.Client{
	cli,err:=client.NewClientWithOpts(client.FromEnv,client.WithAPIVersionNegotiation())
	if err != nil {
		a.sendError("docker 初始化失败",err)
		a.log.Errorln("docker 初始化失败",err)
		return nil
	}
	return cli
}

// GetImageList 获取镜像列表
func (a App) GetImageList() []types.ImageSummary {
	images,err:=a.docker.ImageList(a.ctx,types.ImageListOptions{})
	if err!=nil {
		a.sendError("docker 获取镜像列表失败",err)
		a.log.Errorln("docker 获取镜像列表失败",err)
		return nil
	}
	return images
}

//func ()  {
//
//}